package twosigma;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * Two Sigma code test problem 1 solution
 * 
 * @author yunzhang
 *
 */
public class StringSorter {

	public static void main(String[] args) {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s;
		try {
			while ((s = in.readLine()) != null && s.length() != 0) {
				System.out.println(sortString(s.split(" ")));
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	public static String sortString(String[] strlist) {
		List<Integer> numIdx = new ArrayList<Integer>();
		List<Integer> wordIdx = new ArrayList<Integer>();

		for (int i = 0; i < strlist.length; ++i) {
			Integer val = isInteger(strlist[i]);
			if (val == null)
				wordIdx.add(i);
			else
				numIdx.add(i);
		}

		String[] sortedNumList = sortByIndex(strlist, numIdx, 0);

		String[] sortedList = sortByIndex(sortedNumList, wordIdx, 1);

		return concatStrList(sortedList);
	}

	public static String[] sortByIndex(String[] strlist, List<Integer> idx,
			int flag) {
		if (strlist == null)
			return null;
		if (strlist.length <= 1)
			return strlist;

		for (int i = 0; i < idx.size(); ++i) {
			for (int j = 1; j < idx.size() - i; ++j) {
				if (flag == 0) {
					if (numCompare(strlist[idx.get(j - 1)], strlist[idx.get(j)]) > 0) {
						swap(strlist, idx.get(j - 1), idx.get(j));
					}
				} else {
					if (strCompare(strlist[idx.get(j - 1)], strlist[idx.get(j)]) > 0) {
						swap(strlist, idx.get(j - 1), idx.get(j));
					}
				}
			}
		}
		return strlist;
	}

	public static int numCompare(String s1, String s2) {
		Integer val1 = Integer.valueOf(s1);
		Integer val2 = Integer.valueOf(s2);
		return val1 - val2;
	}

	public static int strCompare(String s1, String s2) {
		return s1.compareTo(s2);
	}

	public static Integer isInteger(String str) {
		try {
			return Integer.valueOf(str);
		} catch (NumberFormatException e) {
			return null;
		}
	}

	public static void swap(String[] strlist, int i, int j) {
		String tmp = strlist[i];
		strlist[i] = strlist[j];
		strlist[j] = tmp;
	}

	public static String concatStrList(String[] strlist) {
		if (strlist == null || strlist.length == 0) {
			return "";
		}

		StringBuffer sb = new StringBuffer();
		for (String str : strlist) {
			sb.append(str).append(" ");
		}
		sb.deleteCharAt(sb.length() - 1);
		return sb.toString();
	}

}
